import { reqGetStu } from "@/api/reqStu";
import type { StudentForm } from "@/types/student";
import { ElMessage } from "element-plus";
import { onMounted, ref, watch, watchEffect } from "vue";

export const useShowStu = () => {
  const stuList = ref<StudentForm>();
  const changeRef = ref(Symbol());

  // 页码
  const npRef = ref(1);
  const sizeRef = ref(10);
  const totalRef = ref(0);

  const getAllStuByPage = async (
    page: number,
    size: number,
    searchMap: any = {}
  ) => {
    const {
      status,
      data: { data, total },
    } = await reqGetStu({ page, size, searchMap });
    stuList.value = data;

    if (status === 0) {
      stuList.value = data;
      totalRef.value = total;
    }
  };


  return {
    stuList,
    changeRef,
    npRef,
    sizeRef,
    totalRef,
    getAllStuByPage,
  };
};
